package com.apache.gateway.config;

import com.apache.gateway.route.DynamicRouteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @description: 定时刷新路由
 * @author: Hou Dayu
 * @date: Created in 2021/2/22
 */
@EnableScheduling
@Component
public class SchedulerRoutes {

    @Autowired
    private DynamicRouteService dynamicRouteService;

    //@Scheduled(initialDelay=60000, fixedDelay=30000)//第一次延迟1分种执行，然后在上一次执行完毕时间点30秒再次执行；
    public void testTasks() {
        try {
            dynamicRouteService.loadRouteConfig(false);
        }catch (Exception e){}
    }
}
